<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
<title></title>
</head>
<body>
<script type="text/javascript">
function TestDemo(pattern, str){
	var result; 								//声明变量
	if (pattern.test(str)){						//测试是否存在指定的模式
		result = "匹配"; 						//定义变量值
	}else{
	 	result = "不匹配"; 				//定义变量值
	}
	document.write("正则表达式"+pattern+result+"字符串\""+str+"\""); //返回字符串
}
TestDemo(/[A-Z][a-z]/ ,"JavaScript从入门到精通");//调用函数并输出结果
</script>
</body>
</html>

